package com.crawler.richtext.htmlparser;

import com.crawler.richtext.htmlparser.tags.*;
import org.htmlparser.Parser;
import org.htmlparser.PrototypicalNodeFactory;
import org.htmlparser.lexer.Lexer;
import org.htmlparser.util.ParserException;
import org.htmlparser.util.ParserFeedback;

/**
 * 自定义Html解析器
 * @author rubekid
 *
 * 2017年12月6日 上午11:18:33
 */
public class HtmlParser extends Parser {
	
	private static PrototypicalNodeFactory factory = null;

	// 注册自定义标签
	static {
		factory = new PrototypicalNodeFactory();
		factory.registerTag(new FontTag());
		factory.registerTag(new StrongTag());
		factory.registerTag(new ArticleTag());
		factory.registerTag(new SectionTag());
		factory.registerTag(new UTag());
	}
	
	public HtmlParser() {
		super();
		setNodeFactory(factory);
	}
	
	public HtmlParser(String resource) throws ParserException{
		super(resource);
		setNodeFactory(factory);
	}

	public HtmlParser(Lexer lexer, ParserFeedback fb) {  
        super(lexer, fb);  
        setNodeFactory(factory);  
    }
}
